import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace BookingOrderDetailApi {
  /** 预约订单明细信息 */
  export interface BookingOrderDetail {
    id: number; // 订单明细ID
    bookingOrderId?: number; // 预约订单ID
    detailCode?: string; // 明细编码
    sequenceNo?: number; // 明细序号
    itemType?: string; // 商品类型
    itemId?: number; // 商品ID
    itemName?: string; // 商品名称
    itemCode: string; // 商品编码
    itemCategory: string; // 商品分类
    quantity?: number; // 预约数量
    estimatedUnitPrice?: number; // 预估单价
    estimatedTotalAmount?: number; // 预估总金额
    estimatedDiscountRate: number; // 预估折扣率(%)
    estimatedDiscountAmount: number; // 预估折扣金额
    estimatedFinalAmount?: number; // 预估最终金额
    estimatedDurationMinutes: number; // 预估时长(分钟)
    detailStatus?: string; // 明细状态
    specialRequirements: string; // 特殊需求
    detailNotes: string; // 明细备注
  }
}

/** 查询预约订单明细分页 */
export function getBookingOrderDetailPage(params: PageParam) {
  return requestClient.get<PageResult<BookingOrderDetailApi.BookingOrderDetail>>('/spa/booking-order-detail/page', { params });
}

/** 查询预约订单明细详情 */
export function getBookingOrderDetail(id: number) {
  return requestClient.get<BookingOrderDetailApi.BookingOrderDetail>(`/spa/booking-order-detail/get?id=${id}`);
}

/** 新增预约订单明细 */
export function createBookingOrderDetail(data: BookingOrderDetailApi.BookingOrderDetail) {
  return requestClient.post('/spa/booking-order-detail/create', data);
}

/** 修改预约订单明细 */
export function updateBookingOrderDetail(data: BookingOrderDetailApi.BookingOrderDetail) {
  return requestClient.put('/spa/booking-order-detail/update', data);
}

/** 删除预约订单明细 */
export function deleteBookingOrderDetail(id: number) {
  return requestClient.delete(`/spa/booking-order-detail/delete?id=${id}`);
}


/** 导出预约订单明细 */
export function exportBookingOrderDetail(params: any) {
  return requestClient.download('/spa/booking-order-detail/export-excel', { params });
}

